package com.kmxd.ams.core.exception;

import javax.validation.constraints.NotNull;

/**
 * 用于业务提示
 *
 * @author ZuoLG
 */
public class BizTipException extends AbstractException {

  public BizTipException(
      @NotNull final LogInfo recordInfo, @NotNull String errorCode, String debugMessage) {
    super(recordInfo, errorCode, debugMessage);
    this.code = errorCode;
    this.debugMessage = debugMessage;
  }

  public BizTipException(@NotNull final LogInfo recordInfo, @NotNull String errorCode) {
    super(recordInfo, errorCode);
    this.code = errorCode;
  }

  public static BizTipException instance(@NotNull String errorCode) {
    return new BizTipException(LogInfo.newCallerInstance(), errorCode);
  }

  public static BizTipException instance(@NotNull String errorCode, String debugMessage) {
    return new BizTipException(LogInfo.newCallerInstance(), errorCode, debugMessage);
  }

  public static void throwException(@NotNull final LogInfo recordInfo, @NotNull String errorCode) {
    throw new BizTipException(recordInfo, errorCode);
  }

  public static void throwException(@NotNull String errorCode, String debugMessage) {
    throw new BizTipException(LogInfo.newCallerInstance(), errorCode, debugMessage);
  }

  @Override
  public String toString() {
    return "BizTipException{} " + super.toString();
  }
}
